<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">定时任务列表</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            <div class="am-u-sm-12 am-u-md-3">
                                <div class="am-form-group">
                                    <?php if (checkPrivilege('develop.crontab/add')): ?>
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a class="am-btn am-btn-default am-btn-success"
                                               href="<?= url('develop.crontab/add') ?>">
                                                <span class="am-icon-plus"></span> 新增
                                            </a>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>

                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>类型</th>
                                <th>任务名称</th>
                                <th>最多执行</th>
                                <th>执行次数</th>
                                <th>开始时间</th>
                                <th>结束时间</th>
                                <th>下次预计时间</th>
                                <th>最后执行时间</th>
                                <th>权重</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle"><?= $item['id'] ?></td>
                                    <td class="am-text-middle">
                                        <?php if ($item['type'] == 'url') : ?>
                                            <span class="x-color-green">请求URL</span>
                                        <?php elseif ($item['type'] =='sql' ) : ?>
                                            <span class="x-color-yellow">执行SQL</span>
                                        <?php else: ?>
                                            <span class="x-color-red">执行Shell</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="am-text-middle"><?= $item['title'] ?></td>
                                    <td class="am-text-middle">
                                        <p class="item-title">
                                            <?= $item['maximums'] ? $item['maximums'] : '无限制'  ?>
                                        </p>
                                    </td>
                                    <td class="am-text-middle"><p class=""><?= $item['executes'] ?></p></td>
                                    <td class="am-text-middle"><?= format_time($item['begintime']) ?></td>
                                    <td class="am-text-middle"><?= format_time($item['endtime']) ?></td>
                                    <td class="am-text-middle"><?= format_time($item['nexttime']) ?></td>
                                    <td class="am-text-middle"><?= format_time($item['executetime']) ?></td>
                                    <td class="am-text-middle"><?= $item['weigh'] ?></td>
                                    <td class="am-text-middle">
                                        <?php if ($item['status'] ==1) : ?>
                                            <span class="x-color-green">正常</span>
                                        <?php elseif ($item['status'] ==2) : ?>
                                            <span class="x-color-yellow">完成</span>
                                        <?php elseif ($item['status'] ==3) : ?>
                                            <span class="x-color-yellow">超时</span>
                                        <?php else: ?>
                                            <span class="x-color-red">禁用</span>
                                        <?php endif; ?>
                                    </td>


                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <?php if (checkPrivilege('develop.crontab/edit')): ?>
                                                <a class="tpl-table-black-operation-default"
                                                   href="<?= url('develop.crontab/edit', ['id' => $item['id']]) ?>">
                                                    <i class="am-icon-pencil"></i>编辑
                                                </a>
                                            <?php endif; ?>
                                            <?php if (checkPrivilege('develop.crontab/delete')): ?>
                                                <a href="javascript:void(0);"
                                                   class="item-delete tpl-table-black-operation-default"
                                                   data-id="<?= $item['id'] ?>">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                            <?php endif; ?>
                                            <?php if (checkPrivilege('develop.crontab_log/index')): ?>
                                                <a class="tpl-table-black-operation-default"
                                                   href="<?= url('develop.crontab_log/index', ['id' => $item['id']]) ?>">
                                                    <i class="iconfont icon-order-o"></i>日志信息
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="11" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        // 删除元素
        var url = "<?= url('develop.crontab/delete') ?>";
        $('.item-delete').delete('id', url);

    });
</script>

